Skip to content

Add JMH benchmark harness - #3

Merged
nishchay06 merged 1 commit into
mainfrom
bench/jmh-harness
Jul 29, 2026
Merged

Add JMH benchmark harness#3
nishchay06 merged 1 commit into
mainfrom
bench/jmh-harness

Conversation

@nishchay06

Copy link
Copy Markdown
Owner

The test suite proves the queue is correct. Nothing measured whether it is fast. This adds that.

What it measures

Benchmark Mode Axes
RoundTripBenchmark.throughput Throughput payload 64B/1KB/8KB × memory/wal
RoundTripBenchmark.latency SampleTime same — gives p50/p90/p99/p999
ConcurrencyBenchmark.contendedRoundTrip Throughput thread count × memory/wal
./benchmarks.sh                      # full suite
./benchmarks.sh RoundTrip -f 1 -wi 1 -i 2 -r 1s   # quick check

Early results

Preliminary, short-run, on a single dev machine — the full suite will produce the real numbers.

Durability costs 32×. At 1 KB payloads:

durability throughput
memory 1,856,836 ops/s
wal 56,950 ops/s

Worth noting WalWriter calls BufferedWriter.flush(), which reaches the OS page cache but never fsyncs. So this 32× buys durability against process crash, not against power loss. A true fsync would cost considerably more.

Concurrency scales negatively:

threads throughput scaling
1 1,788,016 ops/s 1.00×
4 1,231,278 ops/s 0.69×

MessageQueue guards a LinkedList with a single monitor, so four threads contend rather than parallelise. Publishing this as-is — it is an honest measurement and a concrete target for a later change.

Build notes

Two non-obvious things, both commented in place:

  • <proc>full</proc> is required. JDK 23+ defaults to -proc:none; without it JMH's processor runs silently, emits no BenchmarkList, and the suite reports zero benchmarks with no error.
  • exec:java cannot run JMH. It forks a JVM per trial, and Maven's classloader gives the fork no usable java.class.path (ClassNotFoundException: ForkedMain). benchmarks.sh resolves a real classpath instead.

🤖 Generated with Claude Code

Measures the publish -> consume -> acknowledge round trip as throughput and
as a latency distribution, across payload size and durability mode, plus a
contended multi-threaded variant.

The round trip is the unit of work rather than a bare publish: publishing
without consuming grows the queue without bound, so a long run would measure
allocation pressure instead of queue behaviour.

Two notes on the build. JDK 23+ defaults to -proc:none, so proc=full is
required or the annotation processor silently generates nothing. And JMH
forks a JVM per trial, which exec:java cannot supply a usable classpath for,
hence benchmarks.sh building one explicitly.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@nishchay06
nishchay06 merged commit 84ac8bb into main Jul 29, 2026
@nishchay06 nishchay06 mentioned this pull request Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant